package com.chat.service;

import com.chat.common.Message;
import com.chat.common.MessageType;
import com.chat.common.User;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class Resetpassword {
    private static final User user=new User();
    private static final Message msg=new Message();
    private static Socket socket;

    public static void resetpassword(String mailbox, String password){
           try {
               socket=new Socket(InetAddress.getByName("127.0.0.1"),9999);
               ObjectOutputStream oos=new ObjectOutputStream(socket.getOutputStream());

               msg.setMesType(MessageType.MESSAGE_RESET_PWD);
               user.setMailbox(mailbox);
               user.setPassword(password);
               msg.setData(user);
               oos.writeObject(msg);
               oos.flush();

           } catch (IOException e) {
               e.printStackTrace();
           }finally {
               try {
                   socket.close();
               } catch (IOException e) {
                   e.printStackTrace();
               }
           }
       }
}
